﻿////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// <copyright>Copyright 2008-2011 Andreas Huber Doenni</copyright>
// Distributed under the Microsoft Public License (Ms-PL).
// See accompanying file License.txt or copy at http://mews.codeplex.com/license.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace Mews.Net.Nntp
{
    using System;
    using System.Collections.Generic;
    using System.IO;

    /// <summary>Represents a GROUP command to be sent to an NNTP server, see
    /// <a href="http://www.ietf.org/rfc/rfc3977.txt">RFC 3977</a> 6.1.1.</summary>
    /// <threadsafety static="true" instance="false"/>
    public sealed class GroupCommand : SingleLineCommand<GroupResponse, long, long, long, string>
    {
        private static readonly string[] successResponseCodes = { "211" };

        /// <summary>Initializes a new instance of the <see cref="GroupCommand"/> class.</summary>
        /// <exception cref="ArgumentNullException"><paramref name="name"/> equals <c>null</c>.</exception>
        /// <exception cref="ArgumentException"><paramref name="name"/> contains white space.</exception>
        public GroupCommand(string name) : base("GROUP " + name, successResponseCodes)
        {
            CommandHelper.AssertContainsNoWhiteSpace("name", name);
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>See <see cref="SingleLineCommandBase{T, U, V, W, X, Y}.CreateResponse(V, W, X, Y, Stream)"/>.
        /// </summary>
        protected sealed override GroupResponse CreateResponse(
            long p1, long p2, long p3, string p4, Stream subsequentLines)
        {
            subsequentLines.Dispose();
            return new GroupResponse(p1, p2, p3, p4);
        }

        /// <summary>See <see cref="CommandBase{T, U}.IsMultilineResponse"/>.</summary>
        /// <returns>Always <c>false</c>.</returns>
        protected sealed override bool IsMultilineResponse(IList<string> initialResponseLineWords)
        {
            return false;
        }
    }
}
